1. 启动grafana容器后把grafana.ini文件cp到本地
docker cp grafana:/etc/grafana/grafana.ini ./

2. 修改grafana.ini文件（查找到server项直接添加相关信息即可）
[server]
domain = 192.168.10.1
root_url = %(protocol)s://%(domain)s:%(http_port)s/grafana/
serve_from_sub_path = true
allowed_origins= *

3. 添加grafana.ini映射，重新启动grafana容器
services:

  grafana:
    image: rs.grafana:19.03.8
    container_name: grafana
    restart: always
    network_mode: bridge
    ports:
      - "6000:3000"
    volumes:
      - "./data:/var/lib/grafana"
      - "./logs:/var/log/grafana"
      - "./grafana.ini:/etc/grafana/grafana.ini"

4. 添加nginx代理
    location /grafana/ {
       rewrite ^/grafana/(.*)$ /$1 break;
       proxy_pass http://192.168.10.1:6000/grafana;
       proxy_set_header Host $host;
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_set_header X-Forwarded-Proto $scheme;
    }

5. 访问验证
nginx执行reload，通过代理的 localhost:port/grafana/ 进行访问即可